using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ApplicationProperty : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //ViewAllKeys();
        //ViewKeys();
        //GetAllValues();
        GetValueByGetMethod();
    }
    void ViewAllKeys()
    {
        Literal1.Text =
        "View all keys in Application object by AllKeys property<br>";
        foreach(string application in Application.AllKeys)
        {
            Literal1.Text +=application +"<br>";
        }
    }
    void ViewKeys()
    {
        Literal2.Text =
        "View all keys in Application object"
        +" by Keys property<br>";
        foreach (string application in Application.Keys)
        {
            Literal2.Text += application + "<br>";
        }
    }
    void GetAllValues()
    {
        Literal3.Text =
        "Get value of key in Application "+
        " object by GetKey method<br>";
        for (int i=0;i<Application.Count;i++)
        {
            Literal3.Text += Application.GetKey(i) +
            "=" +Application[i].ToString() + "<br>";
        }
    }
    void GetValueByGetMethod()
    {
        Literal4.Text =
        "Get value of key in " +
        " Application object by Get method<br>";
        foreach (string application in Application.AllKeys)
        {
            Literal4.Text += application +"=" 
            +Application.Get(
            application).ToString() + "<br>";
        }
    }
    void LockAndUnLockMethods()
    {
        Literal1.Text =
        "Lock and Unlock " +
        " Application object<br>";
        Application.Lock();
        Application["SiteHitCounter"] =
        (int)Application["SiteHitCounter"] + 1;
        Application.UnLock();
    }
    void RemoveMethods()
    {
        Literal1.Text =
        "Remove Application objects<br>";
        Application.Remove("SiteHitCounter");
        Application.RemoveAt(1);
        Application.RemoveAll();
    }
}
